package com.bw.ppx.splash;

import android.view.View;

import androidx.lifecycle.Observer;
import androidx.viewbinding.ViewBinding;

import com.alibaba.android.arouter.launcher.ARouter;
import com.bw.common.entity.LiveDataEntity;
import com.bw.common.mvvm.view.BaseActivity;
import com.bw.common.utils.ToastShowUtils;
import com.bw.ppx.databinding.ActivitySplashBinding;

import java.lang.ref.WeakReference;

public class SplashActivity extends BaseActivity<ActivitySplashBinding, SplashViewModel> {
    @Override
    public View bindLayout() {
        return v.getRoot();
    }

    @Override
    public ViewBinding initBinding() {
        ActivitySplashBinding binding = ActivitySplashBinding.inflate(inflater);
        return binding;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {

    }

    @Override
    public String getClassNames() {
        return this.getClass().getName();
    }

    @Override
    protected void handleMessage(LiveDataEntity entity) {
        switch (entity.action) {
            case START_VIEW_MODEL:
                int time = (int) entity.data.get(LiveDataEntity.LiveDataType.SPLASH_TIME);
                v.splashTime.setText(time + "s");
                if (time == 0) {
                    ARouter.getInstance().build("/app/frameactivity")
                            .navigation();
                }
                break;
        }
    }
}
